<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>cat</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_000_267">&nbsp;</a>NAME</h4><blockquote>
cat - concatenate and print files
</blockquote><h4><a name = "tag_000_000_268">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

cat <b>[</b>-u<b>][</b><i>file</i> ...<b>]
</b></code>
</pre>
</blockquote><h4><a name = "tag_000_000_269">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>cat</i>
utility reads files in sequence
and writes their contents to the standard output
in the same sequence.
</blockquote><h4><a name = "tag_000_000_270">&nbsp;</a>OPTIONS</h4><blockquote>
The
<i>cat</i>
utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b>&nbsp;</a> .
<p>
The following option is supported:
<dl compact>

<dt><b>-u</b>
<dd>Write bytes from the input file to the standard output
without delay as each is read.

</dl>
</blockquote><h4><a name = "tag_000_000_271">&nbsp;</a>OPERANDS</h4><blockquote>
The following operand is supported:
<dl compact>

<dt><i>file</i><dd>A pathname of an input file.
If no
<i>file</i>
operands are specified,
the standard input is used.
If a
<i>file</i>
is "-", the
<i>cat</i>
utility will read from the standard input at that point in the sequence.
The
<i>cat</i>
utility will not close and reopen standard input when
it is referenced in this way, but will accept multiple occurrences of
"-" as a
<i>file</i>
operand.

</dl>
</blockquote><h4><a name = "tag_000_000_272">&nbsp;</a>STDIN</h4><blockquote>
The standard input is used only if no
<i>file</i>
operands are specified, or if a
<i>file</i>
operand is "-".
See the INPUT FILES section.
</blockquote><h4><a name = "tag_000_000_273">&nbsp;</a>INPUT FILES</h4><blockquote>
The input files can be any file type.
</blockquote><h4><a name = "tag_000_000_274">&nbsp;</a>ENVIRONMENT VARIABLES</h4><blockquote>
The following environment variables affect the execution of
<i>cat</i>:
<dl compact>

<dt><i>LANG</i><dd>Provide a default value for the internationalisation variables
that are unset or null.
If
<i>LANG</i>
is unset or null, the corresponding value from the
implementation-dependent default locale will be used.
If any of the internationalisation variables contains an invalid setting, the
utility will behave as if none of the variables had been defined.

<dt><i>LC_ALL</i><dd>
If set to a non-empty string value,
override the values of all the other internationalisation variables.

<dt><i>LC_CTYPE</i><dd>
Determine the
locale for the interpretation of sequences of bytes of text data as
characters (for example, single- as opposed to multi-byte characters
in arguments).

<dt><i>LC_MESSAGES</i><dd>
Determine the locale that should be used to affect
the format and contents of diagnostic
messages written to standard error.

<dt><i>NLSPATH</i><dd>
Determine the location of message catalogues
for the processing of
<i>LC_MESSAGES .
</i>
</dl>
</blockquote><h4><a name = "tag_000_000_275">&nbsp;</a>ASYNCHRONOUS EVENTS</h4><blockquote>
Default.
</blockquote><h4><a name = "tag_000_000_276">&nbsp;</a>STDOUT</h4><blockquote>
The standard output will contain the sequence of bytes read from
the input files.
Nothing else will be written to the standard output.
</blockquote><h4><a name = "tag_000_000_277">&nbsp;</a>STDERR</h4><blockquote>
Used only for diagnostic messages.
</blockquote><h4><a name = "tag_000_000_278">&nbsp;</a>OUTPUT FILES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_000_279">&nbsp;</a>EXTENDED DESCRIPTION</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_000_280">&nbsp;</a>EXIT STATUS</h4><blockquote>
The following exit values are returned:
<dl compact>

<dt>0<dd>All input files were output successfully.

<dt>&gt;0<dd>An error occurred.

</dl>
</blockquote><h4><a name = "tag_000_000_281">&nbsp;</a>CONSEQUENCES OF ERRORS</h4><blockquote>
Default.
</blockquote><h4><a name = "tag_000_000_282">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
The
<b>-u</b>
option has value in
prototyping non-blocking reads from FIFOs.
The intent is to support the following sequence:
<pre>
<code>
mkfifo foo
cat -u foo &gt; /dev/tty13 &amp;
cat -u &gt; foo
</code>
</pre>
<p>
It is unspecified whether standard output
is or is not buffered in the
default case.
This is sometimes of interest when standard output is associated
with a terminal, since buffering may delay the output.
The presence of the
<b>-u</b>
option guarantees that unbuffered
I/O
is available.
It is implementation-dependent whether the
<i>cat</i>
utility buffers output if the
<b>-u</b>
option is not specified.
Traditionally, the
<b>-u</b>
option is implemented using the
equivalent of the <b>XSH</b> specification
<i><a href="../xsh/setvbuf.html">setvbuf()</a></i>
function.
</blockquote><h4><a name = "tag_000_000_283">&nbsp;</a>EXAMPLES</h4><blockquote>
The following command:
<pre>
<code>
cat myfile
</code>
</pre>
writes the contents of the file
<b>myfile</b>
to standard output.
<p>
The following command:
<pre>
<code>
cat doc1 doc2 &gt; doc.all
</code>
</pre>
concatenates the files
<b>doc1</b>
and
<b>doc2</b>
and writes the result to
<b>doc.all</b>.
<p>
Because of the shell language mechanism used to
perform output redirection, a
command such as this:
<pre>
<code>
cat doc doc.end &gt; doc
</code>
</pre>
causes the original data in
<b>doc</b>
to be lost.
<p>
The command:
<pre>
<code>
cat start - middle - end &gt; file
</code>
</pre>
when standard input is a terminal, gets two arbitrary pieces of
input from the terminal with a single invocation of
<i>cat</i>.
Note, however, that if standard input is a regular file, this would be
equivalent to the command:
<pre>
<code>
cat start - middle /dev/null end &gt; file
</code>
</pre>
because the entire contents of the file would be consumed by
<i>cat</i>
the first time "-" was used as a
<i>file</i>
operand and an end-of-file
condition would be detected immediately when "-" was referenced
the second time.
</blockquote><h4><a name = "tag_000_000_284">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_000_285">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="more.html">more</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
